<?php
if($status!=1){
    exit("<script>window.location.replace(\"./index.php?pa=3\")</script>");
}else{

}
?>
<div id="token" style="background-color: #F7F7F7;width:85%;height: 100%;float: right;overflow:auto;">
<div style="width: 100%;height: 50px;background-color: #B9FFD1;"><h3 style="padding: 10px 2%;margin: 0px;">面板授权</h3></div>
<p style="color:red">*请保管好临时授权管理面板的网址，不要在公共平台泄露</p>
<table border="1">
<tr>
        <td>临时授权管理面板网址</td>
        <td>授权ID</td>
        <td>有效时间(分钟）</td>
        <td>是否有效</td>
        <td>操作</td>
</tr>
<?php 
$con=mysqli_connect($servername,$username,$password,$dbname);
$result = mysqli_query($con,"SELECT * FROM star_php_token WHERE status='1'");
while($row = mysqli_fetch_array($result)){
    if(time()<time()+$row['time']){$status="<p style='color:green'>有效</p>";}else{$status="<p style='color:red'>失效</p>";}
    echo "<tr><td><a href='./admin/?token=".$row['id']."'>".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URL"]."./admin/?token=".$row['id']."</a></td><td>".$row["id"]."</td><td>".$row["time"]."</td><td>".$status."</td><td>"."<button onclick='window.location.replace(\"./index.php?mode=del_token&id=".$row["id"]."\")'>删除</button>"."</td></tr>";
}
?>
</table>
<button onclick='$("#off_token").show();$("#make_token").hide();$("#new_token_div").show();' id='make_token' style='background-color:green;color:white;'>新建授权</button>
<button onclick='$("#off_token").hide();$("#make_token").show();$("#new_token_div").hide();' id='off_token' style='display:none;background-color:green;color:white;'>取消</button>
<form action="./index.php" method="get" style="display: none;" id="new_token_div">
    <p>请输入有效时间（分钟）:<input name="time" type="text"></p>
    <input name="mode" value="new_token" style="display: none;">
    <input value="确定" type="submit" name="new_token_div">
</from>
</div>